<template>
<view>
	<image class="banner" :src="imgUrl+banner"></image>
	<view class="list" v-for="(item,index) in list" :key="index">
		<image class="list_left" :src="imgUrl+item.img"></image>
		<view class="list_right">
			<view class="name">{{item.name}}</view>
			<view class="remark">联系人:{{item.user}}</view>
			<view class="remark">电话:{{item.phone}}</view>
			<view class="remark">地址:{{item.address}}</view>
		</view>
	</view>
	
</view>		
</template>

<script>
import request from '@/util/request.js'
export default {
	data() {
		return {
			imgUrl:this.url,
			banner:'',
			page:1,
			pageShow:true,
			list:[]
		}
	},
	onLoad:function(){
		uni.showLoading({  
		    title: '加载中'  
		});
		this.getBanner()
		this.getList()
	},
	methods: {
		getBanner:function(){
			var that = this;
			var data = {'type':5}
			request({
				url: 'banner',
				method: 'get',
				data:data,
				success: (res) => {
					uni.hideLoading();
					that.banner = res.data.data[0].img
				}
			})
		},
		onReachBottom: function(){
			if(this.pageShow){
				 //当前不是最后一页可加载
				 this.page = this.page + 1
				 uni.showLoading()
				 this.getList();
			}
		},
		getList:function(){
			var that = this;
			var data = {page:this.page}
			request({
				url: 'factory/list',
				method: 'get',
				data:data,
				success: (res) => {
					if(res.data.code == 1){
						if(res.data.data.last_page <= that.page){
							that.pageShow = false
						}
						if(that.page == 1){
							that.list = res.data.data.data
						}else{
							var list = that.list
							that.list = list.concat(res.data.data.data)
						}
					}
				}
			})
		},
	}
}
</script>

<style>
.banner {
	width: 100%;
	height:240rpx;
}
.list{
	display: flex;
	flex-direction: row;
	padding:15rpx 15rpx 15rpx 15rpx;
	border-bottom: 1rpx solid #000000;
}
.list_left{
	width:40%;
	height:220rpx;
}
.list_right{
	width:70%;
	padding:10rpx 10rpx 10rpx 10rpx;
}
.name{
	font-weight: bold;
}
.remark{
	font-size:15px;
	margin-top:8rpx;
}
</style>
